Routing
Routing policies
Route by cost, speed, quality or context — in a file you can commit.
A policy is an ordered list of rules. The first rule whose when matches decides the model; if none match, the default rule does.
Shape
name: production
rules:
- when: task == "summarize"
then: cheapest_above(quality: 80)
- when: context_tokens > 400_000
then: model("google/gemini-3.1-pro")
- when: p95_latency > 800ms
then: fallback_next
default: best_quality(max_input_price: 5.00)
Selectors
| Selector | Picks |
|---|---|
cheapest_above(quality) | The lowest blended price with a score at or above the floor |
fastest(within_quality) | The lowest p50 first-token latency within N points of the best score |
best_quality(max_input_price) | The highest score that costs no more than the cap |
longest_context | The largest context window in the pool |
model(id) | Exactly that model |
Task detection
The task field is inferred from the request unless you set the x-prism-task header. Detection is a small classifier that runs in the router, adds under a millisecond, and is logged so you can check it.
Committing policies
Policies are YAML. Keep them in your repo and push with prism policies push; the dashboard editor reads and writes the same format.